package com.example.itcacp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.itcacp.entity.Category;
import com.example.itcacp.repository.mybatis.CategoryMapper;
import com.example.itcacp.service.CategoryService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {

    @Resource
    private CategoryMapper categoryMapper;

    /**
     * 查询全部
     * */
    @Override
    public List<Category> selectCateAll() {
        return categoryMapper.selectCateAll ( null );
    }

    /**
     * 分页查询
     * */
    @Override
    public PageInfo<Category> selectCatePage(Integer pageNum, Integer pageSize, String categoryName) {
        PageHelper.startPage ( pageNum, pageSize ); // 开启分页查询
        List<Category> categoryList = categoryMapper.selectCateAll ( categoryName );
        return PageInfo.of ( categoryList );
    }



}
